#include "StdAfx.h"
#include "FlowConfigMapper.h"

namespace DBLayer{

CFlowConfigMapper::CFlowConfigMapper(void)
{
	selectStr = "select FlowID,MatchPrefix,FlowHash from talkflow";
}

CFlowConfigMapper::~CFlowConfigMapper(void)
{
}

std::vector<IVRFlow::CFlowConfig*>* CFlowConfigMapper::GetAll()
{
	if(m_DBType == DBTYPE_MYSQL)
	{
		sql::ResultSet * rs = executeSql(selectStr);
		if(rs == NULL)
			return NULL;

		std::vector<IVRFlow::CFlowConfig*>* flows = new std::vector<IVRFlow::CFlowConfig*>();
		while(rs->next())
		{
			IVRFlow::CFlowConfig* flow = new IVRFlow::CFlowConfig();
			flow->FlowID = rs->getString("FlowID");
			flow->MatchPrefix = rs->getString("MatchPrefix");
			flows->push_back(flow);
		}
		return flows;
	}
	return NULL;
}

}